package com.spring.api.service;

import com.spring.api.entities.Dept;
import com.spring.api.fallbackFactory.ConsumerClientFallBackFactory;
import org.springframework.cloud.openfeign.FeignClient;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;

import java.util.List;

/**
 * @author hezx
 * 通过 @feign 声明的服务去找在eureka注册的服务名称，再根据接口下方的请求寻找服务内部的方法
 */
@FeignClient(value = "MICROSERVICE-PROVIDER", fallbackFactory = ConsumerClientFallBackFactory.class)
public interface ConsumerClientService {

    @RequestMapping("/dept/get/{id}")
    Dept get(@PathVariable("id") Long id);

    /**
     * 客户端通过调用该方法，进而调用@Feign声明的服务的地址
     *
     * @return
     */
    @RequestMapping("/dept/findAll")
    List<Dept> findAll();
}
